import { createApp } from 'vue'
import './style.css'
import App from './App.vue'

// 导入 element-plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// 导入 element-plus 图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 导入 pinia
import pinia from './store/index.js'
import useUserStore from './store/user.js'

const app = createApp(App)

// 使用 pinia
app.use(pinia)

// 注册所有 element-plus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 使用 element-plus 插件
app.use(ElementPlus)

// 初始化应用时从 localStorage 加载用户信息
const userStore = useUserStore()
userStore.loadFromLocalStorage()

app.mount('#app')
